<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head th:include="admin/head :: head" th:with="title=管理员编辑">
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form" action="" lay-filter="formfilter">
            <div class="layui-form-item">
                <label class="layui-form-label">登录名:</label>
                <div class="layui-input-block">
                    <input type="text" th:value="${ m.name}" readonly="readonly"  class="layui-input" >
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red">*</span>密码:</label>
                <div class="layui-input-block">
                    <input type="password" id="pwd" name="pwd" lay-verify="required|pwd" autocomplete="off"  class="layui-input" >
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red">*</span>确认密码:</label>
                <div class="layui-input-block">
                    <input type="password" id="pwd2" name="pwd2" lay-verify="required|pwd2" autocomplete="off"  class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input type="hidden" name="id" th:value="${ m.id}">
                    <button class="layui-btn" lay-submit="" lay-filter="formSubmit">立即提交</button>
                </div>
            </div>
        </form>
    </div>
</div>

<script>
    layui.use(['form','liuQi'], function () {
        var form = layui.form,
            liuQi = layui.liuQi;

        //日期
        form.render();

        //自定义验证规则
        form.verify({
            pwd: function (value) {
                if(value.length<6){
                    return "最少6位字符";
                }
            },
            pwd2: function (value) {
                if($("#pwd").val() != $("#pwd2").val()){
                    return "确认密码不一样";
                }
            },
        });
        //监听提交
        form.on('submit(formSubmit)', function (data) {
            data=data.field;
            liuQi.ajax("/admin/user/modifyPwd",data,
                function (data) {
                    //关闭
                    parent.layer.msg(data.msg);
                    parent.layui.table.reload('currentTableId');
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                }
            );
            return false;
        });
    });
</script>

</body>
</html>